package com.ruoyi.web.controller.cems;

import com.ruoyi.cems.domain.BmsEmergencyManual;
import com.ruoyi.cems.service.IBmsEmergencyManualService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.UUID;

/**
 * 应急手册;Controller
 * 
 * @author ruoyi
 * @date 2024-06-24
 */
@Api(description="应急手册管理")
@RestController
@RequestMapping("/cems/manual")
public class BmsEmergencyManualController extends BaseController
{
    @Autowired
    private IBmsEmergencyManualService bmsEmergencyManualService;

    /**
     * 查询应急手册;列表
     */
    @ApiOperation("查询应急手册")
    @GetMapping("/list")
    public TableDataInfo list(BmsEmergencyManual bmsEmergencyManual)
    {
        startPage();
        List<BmsEmergencyManual> list = bmsEmergencyManualService.selectBmsEmergencyManualList(bmsEmergencyManual);
        return getDataTable(list);
    }

    /**
     * 导出应急手册;列表
     */
    @ApiOperation("导出应急手册")
    @Log(title = "应急手册", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BmsEmergencyManual bmsEmergencyManual)
    {
        List<BmsEmergencyManual> list = bmsEmergencyManualService.selectBmsEmergencyManualList(bmsEmergencyManual);
        ExcelUtil<BmsEmergencyManual> util = new ExcelUtil<BmsEmergencyManual>(BmsEmergencyManual.class);
        util.exportExcel(response, list, "应急手册;数据");
    }

    /**
     * 获取应急手册;详细信息
     */
    @ApiOperation("获取应急手册")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") String ID)
    {
        return success(bmsEmergencyManualService.selectBmsEmergencyManualByID(ID));
    }

    /**
     * 新增应急手册;
     */
    @ApiOperation("新增应急手册")
    @Log(title = "应急手册", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmsEmergencyManual bmsEmergencyManual)
    {
        bmsEmergencyManual.setID(UUID.randomUUID().toString().replace("-", ""));
        return toAjax(bmsEmergencyManualService.insertBmsEmergencyManual(bmsEmergencyManual));
    }

    /**
     * 修改应急手册;
     */
    @ApiOperation("修改应急手册")
    @Log(title = "应急手册", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmsEmergencyManual bmsEmergencyManual)
    {
        return toAjax(bmsEmergencyManualService.updateBmsEmergencyManual(bmsEmergencyManual));
    }

    /**
     * 删除应急手册;
     */
    @ApiOperation("删除应急手册")
    @Log(title = "应急手册", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable String[] IDs)
    {
        return toAjax(bmsEmergencyManualService.deleteBmsEmergencyManualByIDs(IDs));
    }
}
